//
//  HeaderViewCell.m
//  YJTableViewCell
//
//  Created by yuanjiang on 2016/12/15.
//  Copyright © 2016年 YuanJiang. All rights reserved.
//

#import "HeaderViewCell.h"

@interface HeaderViewCell()


@property(nonatomic,assign) NSInteger section;

@end

@implementation HeaderViewCell


-(instancetype)initWithFrame:(CGRect)frame
{
    if (self =  [super initWithFrame:frame]) {
       
        self.backgroundColor= [UIColor whiteColor];
        self.statusLabel = [[UILabel alloc] init];
        [self.statusLabel setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:self.statusLabel];
        [self.statusLabel setTextColor:[UIColor orangeColor]];
        [_statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.mas_centerY);
            make.right.mas_equalTo(self.mas_right).offset(-10);
        }];
        
        self.textlabel = [[UILabel alloc] init];
        [self.textlabel setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:self.textlabel];
        [_textlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.mas_centerY);
            make.left.mas_equalTo(self.mas_left).offset(10);
        }];
        
        self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.moreButton addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.moreButton];
       
        UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(15, 59, [UIScreen mainScreen].bounds.size.width-30, 1)];
        line.backgroundColor = [UIColor blackColor];
        [self addSubview:line];
        
    }
    return self;
}

-(void)clickAction
{
    NSLog(@"dianji btn");
    self.moreButton.selected = !self.moreButton.selected;
    NSLog(@"selected =>%zi",self.moreButton.selected);
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[NSNumber numberWithBool:self.moreButton.selected] forKey:@"isShow"];
    [dic setObject:[NSNumber numberWithInteger:self.section] forKey:@"section"];
    self.yjblock (dic);
}

- (void)setCellNumber:(NSArray *)array section:(NSInteger)section
{
    self.section = section;
    [_moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.height.mas_equalTo(self.mas_height);
        make.width.mas_equalTo(self.mas_width);
    }];
    
}

@end
